﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

namespace AutoRoot
{
   public class ToPrevious : ButtonStateHandler
   {
      public override void Execute()
      {
         print(Global.currentSection.Value.name);
         print(Global.myStory.GetFirst().Value.name);
         if (Global.currentSection != Global.myStory.GetFirst())
         {
            LinkedListNode<Section> current = Global.currentSection;
            Global.currentSection = Global.currentSection.Previous;
            Global.myStory.Remove(current);
            Global.LoadAudio(Global.currentSection.Value.resourcePath);

            GameObject.Find("Progressbar").SendMessage("updateTotalTime", Global.currentAudio.clip.length, SendMessageOptions.DontRequireReceiver);
            GameObject.Find("ButtonPlayOrPause").GetComponent<Play>().Execute();
         }
      }
   }
}
